package listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import jms.JmsMessageConsumer;
@WebListener
public class JmsListener implements ServletContextListener {
	
	private final static Logger logger = LogManager.getLogger(JmsListener.class);
	
	private JmsMessageConsumer consumer;

    public JmsListener() {
    	consumer = new JmsMessageConsumer();
    }

    public void contextInitialized(ServletContextEvent sce) {
    	consumer.consume();
    	logger.info("jms consumer start");
        
    }

    public void contextDestroyed(ServletContextEvent sce) {
    	consumer.close();
    	logger.info("jms consumer destory");
    }
	
}
